package com.i.template.controller;

import cn.hutool.core.bean.BeanUtil;
import com.i.template.constant.ResponseResult;
import com.i.template.domain.RechargeDO;
import com.i.template.domain.vo.RechargeVO;
import com.i.template.service.IRechargeService;
import com.i.template.util.UserHolder;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.ExecutionException;

/**
 * @author lewis
 * @type class
 * @description
 * @since 2024/8/8
 */
@RestController
@RequestMapping("/recharge")
@RequiredArgsConstructor
public class RechargeController {
    private final IRechargeService service;
    @PostMapping
    public ResponseResult<?> saveRechargeInfo(@RequestBody RechargeVO rechargeVO) {
        RechargeDO rechargeDO = BeanUtil.copyProperties(rechargeVO, RechargeDO.class);
        return ResponseResult.judge(service.save(rechargeDO));
    }
    @GetMapping("/expire")
    public ResponseResult<Boolean> expireByRechargeOrder() {
        return ResponseResult.judge(service.expire());
    }
}
